package com.zy.explore.license;

import com.zy.explore.license.infrastructure.license.LicenseCheckListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;
import tk.mybatis.spring.annotation.MapperScan;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * description 应用启动入口类
 *
 * @author 🇨🇳中国印🇨🇳
 * @date 2022年04月17日 02:36:49
 */
@Slf4j
@EnableDiscoveryClient
@SpringBootApplication
@ComponentScan(value = "com.zy.explore.license", excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {LicenseCheckListener.class})
})
@EnableFeignClients(basePackages = {"com.zy.explore.license.*"})
@MapperScan(basePackages = {"com.zy.explore.license.domain.mybatis.dao"})
@org.mybatis.spring.annotation.MapperScan(basePackages = {"com.zy.explore.license.domain.mybatis.dao"})
public class ZyLicenseApplication {

    public static void main(String[] args) throws UnknownHostException {

        ConfigurableApplicationContext application = SpringApplication.run(ZyLicenseApplication.class, args);

        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        if (StringUtils.isEmpty(path)) {
            path = "";
        }
        log.info("\n----------------------------------------------------------\n" +
                "ZyLicenseApplication is running! Access URLs:\n\t" +
                "Local访问网址: \t\thttp://localhost:" + port + path + "\n\t" +
                "External访问网址: \thttp://" + ip + ":" + port + path + "\n\t" +
                "Swagger访问网址: \thttp://localhost:" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");
    }

}